package pl.elka.simulator.core;

import java.util.ArrayList;
import java.util.List;

import pl.elka.simulator.core.configurationCommand.ConfigurationCommandType;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToAreaConstraintConfiguration;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToConstraintConfiguration;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToNodeConfiguration;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToTreasureConfiguration;

public class EnviromentConfiguration implements 
				IAbleToNodeConfiguration,
				IAbleToConstraintConfiguration,
				IAbleToTreasureConfiguration,
				IAbleToAreaConstraintConfiguration{

	private List<Constraint> constraints = new ArrayList<Constraint>();
	private List<Node> nodes = new ArrayList<Node>();
	private List<Treasure> treasures = new ArrayList<Treasure>();
	private AreaConstraint areaConstraint = null;
	
	@Override
	public List<Constraint> getConstraints() {
		return constraints;
	}

	@Override
	public void setConstraints(List<Constraint> cs) {		
		this.constraints = cs;
	}

	@Override
	public List<Node> getNodes() {
		return nodes;
	}

	@Override
	public void setNodes(List<Node> nodes) {
		this.nodes = nodes;
	}

	@Override
	public List<Treasure> getTreasures() {
		return treasures;
	}

	@Override
	public void setTreasures(List<Treasure> treasures) {
		this.treasures = treasures;
	}
	
	public List<ConfigurationCommandType> getAllowedConfigurationCommands(){
		List<ConfigurationCommandType> ret = new ArrayList<ConfigurationCommandType>();
		ret.add(ConfigurationCommandType.AddAreaConstraintConfigurationCommand);
		ret.add(ConfigurationCommandType.AddNodeConfigurationCommand);
		ret.add(ConfigurationCommandType.DeleteNodeConfigurationCommand);
		ret.add(ConfigurationCommandType.AddConstraintConfigurationCommand);
		ret.add(ConfigurationCommandType.DeleteConstraintConfigurationCommand);		
		ret.add(ConfigurationCommandType.AddTreasureConfigurationCommand);
		ret.add(ConfigurationCommandType.DeleteTreasureConfigurationCommand);
		return ret;
	}
	public List<IPaintable> getPaintaibleElements() {
		List<IPaintable> ret = new ArrayList<IPaintable>(nodes.size());
		for(IPaintable p: nodes){
			ret.add(p);
		}
		for(IPaintable p:constraints){
			ret.add(p);
		}
		for(IPaintable p:treasures){
			ret.add(p);
		}
		if(areaConstraint!=null){
			ret.add(areaConstraint);
		}
		return ret;
	}

	@Override
	public AreaConstraint getAreaConstraint() {
		return areaConstraint;
	}

	@Override
	public void setAreaConstraint(AreaConstraint cs) {
		this.areaConstraint = cs;
	}	

}
